package com.rayson.oneapi.gateway.config;

import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Author: rayson
 * Description:
 * Version: 1.0
 * Date: 2024-09-01 22:12
 */
@Configuration
public class RouteConfig {


    @Bean
    public RouteLocator routeLocator(RouteLocatorBuilder builder) {
        return builder.routes()
                // 本地接口
                .route("local", r -> r.path("/api/local/**")
                        .filters(x -> x.stripPrefix(2))
                        .uri("http://localhost:8100"))
                // 外部接口
                .route("external", r -> r.path("/api/**").uri("http://localhost:9527"))
                .build();
    }

}
